package com.fdhwws.web.servlet;

import com.fdh.myjdbcutil.MyJdbcUtil;
import jakarta.servlet.*;
import jakarta.servlet.annotation.WebServlet;

import java.io.IOException;

@WebServlet(urlPatterns = "/init", loadOnStartup = 1)
public class InitServlet implements Servlet {
    @Override
    public void init(ServletConfig servletConfig) throws ServletException {
        MyJdbcUtil.getNewInstance("jdbc:mysql://localhost:3306/chat_room_db", "root", "密码")
                .connectMySQL();
        MyJdbcUtil.getInstance().setIsUseErrorStack(true);
        MyJdbcUtil.getInstance().setIsPrintSql(true);
    }

    @Override
    public ServletConfig getServletConfig() {
        return null;
    }

    @Override
    public void service(ServletRequest servletRequest, ServletResponse servletResponse) throws ServletException, IOException {

    }

    @Override
    public String getServletInfo() {
        return "";
    }

    @Override
    public void destroy() {
        MyJdbcUtil.getInstance().close();
    }
}
